﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;

namespace Metis.Share
{
    public static class Geometries
    {
        public static PathGeometry CreatePolygon(IList<Point> list)
        {
            if (list.Count > 2)
            {
                PathFigure figure = new PathFigure
                                        {
                                            StartPoint = list[0],
                                            Segments = new PathSegmentCollection()
                                        };
                for (int i = 1; i < list.Count; i++)
                {
                    var point = list[i];
                    figure.Segments.Add(new LineSegment(point, true));
                }
                PathGeometry geometry = new PathGeometry();
                geometry.Figures.Add(figure);
                return geometry;
            }
            throw new ArgumentException();
        }
    }
}
